package com.yxuan.springboot.controller;

import com.yxuan.springboot.service.SchoolRangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.yxuan.springboot.model.SchoolRange;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 
 * @author zchao
 *   SchoolRange控制器
 * @date 2023-05-28 18:27:33
 */
@Controller
@Api(tags = "大学排名")
@RequestMapping(value = "/schoolrange", method = {RequestMethod.POST,RequestMethod.GET})
@CacheConfig(cacheNames = "schoolrange")//缓存名，和管理器中配置的一致
public class SchoolRangeController extends BaseController<SchoolRange>{

    @Autowired
    private SchoolRangeService schoolRangeService;

    //根据条件（无条件）查询多个结果
    @ApiOperation(value = "根据条件（无条件）--查询多个结果---", notes = "根据条件（无条件）--查询多个结果--",httpMethod = "GET")
    @RequestMapping("/loadManyByPramas")
    @ResponseBody
    @Cacheable(key = "'loadManyByPramas-' + #t",unless = "#result==null", condition = "#t!=null")//#result返回结果
    public List<SchoolRange> loadManyByPramas(SchoolRange t) {
        try {
            return schoolRangeService.findManyByPramas(t);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
